#include<iostream>
#include<unordered_map>
#include<vector>

using namespace std;
class Solution {
public:
    int subarraysDivByK(vector<int>& nums, int k) {
        unordered_map<int, int> hash;
        hash[0] = 1;
        int sum = 0, ret = 0;
        for (auto ch : nums)
        {
            sum += ch;
            int r = (sum % k + k) % k;
            if (hash.count(r))
            {
                ret += hash[r];
            }
            hash[r]++;
        }
        return ret;
    }
};

int main()
{
    return 0;
}